import { defineStore } from 'pinia';

export const useProductStore = defineStore('product', {
  state: () => ({
    products: [],
  }),
  actions: {
    async fetchProducts() {
      // 实现从 API 或其他数据源获取产品列表的逻辑
      // 以下是新的模拟数据示例，包含不同商品及图片属性，并区分两种类别
      this.products = [
        {
          id: 1,
          name: 'MacBook Pro',
          description: '强大的笔记本电脑，适合专业人士',
          price: 1500,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 2,
          name: 'iPad Air',
          description: '轻薄便携的平板电脑',
          price: 500,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 3,
          name: 'Apple Watch Series 7',
          description: '智能手表，具备多种健康监测功能',
          price: 300,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 4,
          name: 'AirPods Pro',
          description: '无线降噪耳机，提供出色的音质',
          price: 200,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 5,
          name: 'iPhone 14',
          description: '最新款智能手机，拥有先进的拍照功能',
          price: 800,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 6,
          name: 'iMac',
          description: '一体机电脑，设计精美',
          price: 1200,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 7,
          name: 'Apple Pencil',
          description: '适用于iPad的手写笔，书写绘画体验出色',
          price: 100,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 8,
          name: 'HomePod Mini',
          description: '智能音箱，可提供优质的音乐播放',
          price: 100,
          category: 'electronic_devices',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        // 新增的八个配件类商品数据
        {
          id: 9,
          name: 'iPhone Case',
          description: '保护iPhone的手机壳，多种款式可选',
          price: 20,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 10,
          name: 'iPad Keyboard',
          description: '适用于iPad的外接键盘，方便打字输入',
          price: 50,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 11,
          name: 'Apple Watch Band',
          description: '可替换的Apple Watch表带，时尚舒适',
          price: 30,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 12,
          name: 'AirPods Case',
          description: '保护AirPods的充电盒，个性化设计',
          price: 15,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 13,
          name: 'iMac Mouse Pad',
          description: '适配iMac的鼠标垫，手感舒适',
          price: 10,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 14,
          name: 'MacBook Sleeve',
          description: '保护MacBook的电脑包，轻便耐用',
          price: 40,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 15,
          name: 'iPad Stand',
          description: '用于支撑iPad的支架，可调节角度',
          price: 25,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        },
        {
          id: 16,
          name: 'Apple Pencil Tip',
          description: 'Apple Pencil的替换笔尖，保持书写顺滑',
          price: 5,
          category: 'accessories',
          images: ['src/assets/p1.png','src/assets/p2.png']
        }
      ];
    },
  },
});